//
//  LXFirmwareModel.m
//  INMOTION_CustomMadeProject
//
//  Created by cjg on 2021/3/26.
//  Copyright © 2021 cjg. All rights reserved.
//

#import "LXFirmwareModel.h"


@implementation LXFirmwareModel

- (void)loadDataFromResponseData:(NSDictionary *)responseData {
    NSDictionary *data = responseData[@"data"];
    
    if ([data isKindOfClass:[NSDictionary class]] && data.allKeys.count) {
        self.descriptionText = data[@"description"];
        self.firmwareName = data[@"firmwareName"];
        NSArray *versiondata = data[@"version"];
        for (NSDictionary *tempVersionDic in versiondata) {
            self.device = (uint8_t)[tempVersionDic[@"device"] intValue];
            self.fileSize = tempVersionDic[@"fileSize"];
            self.fileUrl = tempVersionDic[@"fileUrl"];
            NSArray *versions = tempVersionDic[@"versions"];
            for (NSDictionary *versionDic in versions) {
                NSString *versionDevice = versionDic[@"device"];
                NSString *version = versionDic[@"version"];
                if ([versionDevice intValue] == 49) {
                    self.version = [self.version stringByAppendingFormat:@"%@(MC),",version];
                }
                if ([versionDevice intValue] == 50) {
                    self.version = [self.version stringByAppendingFormat:@"%@(BT)",version];
                }
            }
        }
        
        NSDictionary *forceUpdate = data[@"forceUpdateInfo"];
        if (forceUpdate) {
            self.level = [forceUpdate[@"level"] intValue];
            self.minVersion = forceUpdate[@"minVersion"];
            self.maxVersion = forceUpdate[@"maxVersion"];
            self.updateDescription = forceUpdate[@"description"];
        }
    }
}

@end
